#ifndef CAMERA_H
#define CAMERA_H
#include <QVector3D>
#include <QMatrix4x4>
#include <QKeyEvent>
#include <QOpenGLShader>
#include <QDebug>

class Camera {
public:
    Camera(QVector3D position = QVector3D(0.0f, 0.0f, 0.0f), int width = 300,int height=300)
    {
        this->cameraPos = position;
        this->lastX = width / 2;
        this->lastY = height / 2;
        cameraPos = QVector3D(0.0f, 0.0f, -10.0f);
    }

public:
    QMatrix4x4 getViewMat();

    void DealMouseMovement(GLfloat Xoffset, GLfloat Yoffset);
    void DealMouseScroll(GLfloat Yoffset);
    void DealKeyboardInputs();
    void DealMouseRightPress();
    void UpdateCameraLookatMatVectors();

public:

    QVector3D cameraPos = QVector3D(0.0f, 0.0f, -10.0f);
    QVector3D lastcameraPos = QVector3D(0.0f, 0.0f, 0.0f);

    QVector3D cameraTarget = QVector3D(0.0, 0.0f, 0.0f);
    QVector3D cameraDirection = QVector3D(cameraPos - cameraTarget);
    QVector3D cameraUp = QVector3D(0.0f, 1.0f, 0.0f);
    QVector3D cameraRight = QVector3D::crossProduct(cameraDirection, cameraUp);

    GLfloat sensitivity = 0.01f;
    GLfloat fov = 5.71059f * 2.0f;

    GLfloat yaw = -86.39f;
    GLfloat pitch = 0.0f;

    GLboolean isFirstMouse = GL_TRUE;
    GLboolean isLeftMousePress = GL_FALSE;
    GLboolean isMouseRightPress = GL_FALSE;
    GLboolean moveCamera = GL_FALSE;

    GLint lastX;
    GLint lastY;
    GLfloat lastXoffset = 0;
    GLfloat lastYoffset = GLfloat(1.570796);

    GLboolean keys[1024] = {0};
};
#endif // CAMERA_H
